import {createRouter, createWebHashHistory} from 'vue-router'
import round00 from '@/app/test1/test1'
import round11 from '@/app/test1/round1'
import round12 from '@/app/test1/round2'
import round13 from '@/app/test1/round3'
import round14 from '@/app/test1/round4'
import round15 from '@/app/test1/round5'
import round16 from '@/app/test1/round6'
import round17 from '@/app/test1/round7'
import round21 from '@/app/test2/round1'
import round22 from '@/app/test2/round2'
import HelloWorld from '@/app/test4/index'
import maze from '@/app/test3/testMaze'
import maze2 from '@/app/test3/testMaze2'
import home from '@/app/testHome'
import A from '@/app/testABC/testA'
import B from '@/app/testABC/testB'
import C from '@/app/testABC/testC'
import R from '@/app/testR/testr'
import End from '@/app/end/test2'
import {getToken} from "@/utils/auth";

const routes = [
    {
        path: '/',
        component: home,
        meta: {title: '测试一'}
    },
    {
        path: '/A',
        component: A,
        meta: {title: '测试一'}
    },
    {
        path: '/B',
        component: B,
        meta: {title: '测试一'}
    },
    {
        path: '/C',
        component: C,
        meta: {title: '测试一'}
    },
    {
        path: '/R',
        component: R,
        meta: {title: '测试一'}
    },
    {
        path: '/end',
        component: End,
        meta: {title: '测试一'}
    },
    {
        path: '/test',
        component: HelloWorld,
        meta: {title: '测试一'}
    },
    {
        path: '/test3',
        component: maze,
        meta: {title: '测试一'}
    },
    {
        path: '/test3/round',
        component: maze2,
        meta: {title: '测试一'}
    },
    {
        path: '/test1',
        component: round00,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round1',
        component: round11,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round2',
        component: round12,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round3',
        component: round13,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round4',
        component: round14,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round5',
        component: round15,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round6',
        component: round16,
        meta: {title: '测试一'}
    },
    {
        path: '/test1/round7',
        component: round17,
        meta: {title: '测试一'}
    },
    {
        path: '/test2/round1',
        component: round21,
        meta: {title: '测试二'}
    },
    {
        path: '/test2/round2',
        component: round22,
        meta: {title: '测试二'}
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})
router.beforeEach((to, from, next) => {
    if (to.fullPath === '/' || typeof (getToken()) != "undefined") {
        next()
    } else {
        console.log(123)
        next({
            path: '/',
            params: {
                from: to.fullPath
            }
        })
    }
})
export default router
